<template>
  <div id="app">
    <div class="tabItem">
      <div
        class="item"
        :class="selctIndex==indexlimt?'colorVit':'borderVit'"
        v-for="(tabItem,indexlimt) in tabTitle"
        :key="indexlimt"
        @click="handlerMorf(indexlimt)"
      >{{tabItem.name}}</div>
    </div>

    <div
      class="recycler"
      v-for="(item,indexData) in data"
      :key="indexData"
      @click="navDetails(item.id)"
    >
      <img class="item_img" :src="item.coverUrl" />
      <div class="item_name">{{item.title}}</div>
      <img class="item_right" src="./right_icon.png" />
    </div>
  </div>
</template>

<script>
export default {
  name: 'starLight',
  data() {
    return {
      selctIndex: this.$route.query.index,
      tid: this.$route.query.tid,
      tabTitle: [],
      data: []
    }
  },
  mounted() {
    let that = this
    this.$http({
      url: 'https://testbzhz.jnbygroup.com/api/gateway/dealer-center/dealer/categoryList',
      method: 'get',
      params: {
        moduleId: that.tid
      }
    }).then(data => {
      if (data.code == 200) {
        console.log(data)
        that.tabTitle = data.data
        that.listData()
      } else {
        this.$toast(data.msg)
      }
    })
  },
  computed: {},
  created: function() {
    // document.title = '员工福利'
  },
  methods: {
    navDetails(cid) {
      this.$router.push({ path: 'detailsView', query: { cid: cid } })
    },

    handlerMorf(indexlimit) {
      this.selctIndex = indexlimit
      this.listData()
    },

    listData() {
      let that = this
      this.$http({
        url: 'https://testbzhz.jnbygroup.com/api/gateway/dealer-center/dealer/queryContentListByCategoryId',
        method: 'post',
        // params: {
        //   tel: '15139678571',
        // },
        data: {
          categoryId: that.tabTitle[that.selctIndex].id
        }
      }).then(data => {
        if (data.code == 200) {
          console.log(data)
          that.data = data.data.records
        } else {
          this.$toast(data.msg)
        }
      })
    }
  }
}
</script>
<style scoped>
#app {
  height: 100vh;
}

.tabItem {
  display: flex;
  align-items: center;
  /* width: 92%; */
  margin-left: 4%;
  overflow: auto;
  flex-wrap: wrap;
}

.tabItem .item {
  font-size: 12px;
  font-weight: 500;
  color: #327542;
  line-height: 32px;
  min-width: 20.55vw;
  padding-left: 15px;
  padding-right: 15px;
  border-radius: 5px;
  margin-top: 10px;
  text-align: center;

  margin-right: 10px;
}

.colorVit {
  border: 1px solid #327542;
  color: #327542;
}

.borderVit {
  border: 1px solid #cdcdcd;
  color: #333333;
}

/* <div id="app">
    <div class="tabItem">
      <div class="item" v-for="(tabItem,indexlimt) in tabTitle" :key="indexlimt">{{tabItem.name}}</div>
    </div>

    <div class="recycler" v-for="(item,indexData) in data" :key="indexData">
      <img class="item_img" />
      <div class="item_name"></div>
    </div>
  </div> */

.recycler {
  width: 92%;
  margin-left: 4%;
  margin-top: 20px;
  display: flex;
  align-items: center;
}

.item_img {
  width: 60px;
  height: 60px;
  overflow: hidden;
  border-radius: 90px;
}

.item_name {
  flex: 1;
  margin-left: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #333333;
}
::-webkit-scrollbar {
  display: none; /* Chrome Safari */
}
.item_right {
  width: 26px;
  height: 26px;
}
</style>